package org.example.business.event.login;

import org.example.objevent.event.Event;
import org.example.objevent.event.EventActor;
import org.example.objevent.event.EventBus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class LoginActor implements EventActor<LoginReq> {

    @Autowired
    private EventBus bus;

    @Override
    public String getWatchEvent() {
        return "login";

    }

    @Override
    public void act(LoginReq data) {

        if(data.getUsername().equalsIgnoreCase(data.getPassword())){

            bus.publish(new Event("login_rsp", new LoginRsp()));

        }

    }

}
